@extends('master')

@section('content')
<div class="management-content">
    <div class="container">
        <div class="record-list">
           @if(Session::get('message'))
          <div class="alert alert-info" role="alert">{{ Session::get('message') }}</div>
           @endif

           @if(Session::get('error'))
          <div class="alert alert-danger" role="alert">{{ Session::get('error') }}</div>
           @endif

            @if($action == 'edit')
            <a href="/categories/management" class="btn btn-default pull-right">添加分类</a>
            @endif
            <h2>分类管理</h2>
            <hr>
            <div class="row">
                <div class="col-sm-6">
                   <div class="categories-list">
                       {{ $categoriesHtmlUl }}
                   </div>

                </div>


                <div class="catefory-form-area col-sm-6">

                    @if($action == 'add')
                    <h4>添加分类</h4>

                    {{ Form::open(array('url' => '/categories/add', 'role' => 'form', 'id' => 'category-add', 'class' => 'col-sm-8')) }}
                       <div class="form-group">
                        {{ Form::label('name', '名称') }}
                        {{ Form::text('name', '', array('class' => 'form-control')) }}
                       </div>
                       <div class="form-group">
                        {{ Form::label('description', '描述') }}
                        {{ Form::textarea('description', '', array('class' => 'form-control', 'rows' => '3')) }}
                       </div>
                       <div class="form-group">
                           {{ Form::label('p_id', '归属') }}
                           <select name="p_id" class="form-control">
                               <option value="1">顶级分类</option>
                               {{ $categoriesHtmlSelect }}
                           </select>

                       </div>



                        {{ Form::submit('添加', array('class' => 'btn btn-primary')) }}
                    {{ Form::close() }}

                    @else

                    <h4>编辑分类</h4>

                    {{ Form::open(array('url' => '/categories/edit', 'role' => 'form', 'id' => 'category-edit', 'class' => 'col-sm-8')) }}
                        {{ Form::hidden('category_id', $currentCategory->id) }}
                       <div class="form-group">
                        {{ Form::label('name', '名称') }}
                        {{ Form::text('name', $currentCategory->name, array('class' => 'form-control')) }}
                       </div>
                       <div class="form-group">
                        {{ Form::label('description', '描述') }}
                        {{ Form::textarea('description', $currentCategory->description, array('class' => 'form-control', 'rows' => '3')) }}
                       </div>
                       <div class="form-group">
                           {{ Form::label('p_id', '归属') }}
                           <select name="p_id" class="form-control">
                               <option value="1">顶级分类</option>
                               {{ $categoriesHtmlSelect }}
                           </select>

                       </div>



                        {{ Form::submit('保存', array('class' => 'btn btn-primary')) }}
                    {{ Form::close() }}
                    @endif

                </div>
            </div>
        </div>

    </div>
</div>
@stop




